package com.isoftstone.agiledev.hrdemo.system.app.internal.user;

import java.util.*;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.isoftstone.agiledev.hrdemo.system.app.user.IUserManager;
import com.isoftstone.agiledev.hrdemo.system.app.user.User;


@Transactional
@Service("userManagerOracleImpl")
public class UserManagerOracleImpl implements IUserManager {

	@Resource
	private SqlSession session = null;
	@SuppressWarnings("unchecked")
	@Override
	public List<User> list(String name, int start, int end, String orderBy) {
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("start", start);
		params.put("end", end);
		params.put("name", name);
		return session.selectList("com.isoftstone.agiledev.hrdemo.system.app.user.UserMapper.oracle.list",params);
	}

	@Override
	public void add(User user) {
		user.setId((int) System.currentTimeMillis());
		session.insert("com.isoftstone.agiledev.hrdemo.system.app.user.UserMapper.oracle.save",user);
	}

	@Override
	public void update(User user) {

	}

	@Override
	public void remove(int id) {
		session.delete("com.isoftstone.agiledev.hrdemo.system.app.user.UserMapper.oracle.remove",id);

	}

	@Override
	public void remove(int[] ids) {

	}

	@Override
	public User findById(int id) {
		return null;
	}

	@Override
	public int getTotal(String name) {
		return (Integer)session.selectOne("com.isoftstone.agiledev.hrdemo.system.app.user.UserMapper.oracle.total", name);
	}
}
